# configuration
sed -i '/mysqld/a\skip-grant-tables' /etc/my.cnf
systemctl restart mysqld
mysql -P {{ mysql_port }} -u root -e "use mysql; update mysql.user set authentication_string=password('root') where user='root' ;flush privileges;"
sed -i '/skip-grant-tables/s/^/#/' /etc/my.cnf
systemctl restart mysqld

mysql -P {{ mysql_port }} -uroot -proot --connect-expired-password -e "SET PASSWORD = PASSWORD('{{ rootpass }}');"

# 修改登陆策略
mysql -P {{ mysql_port }} -u root -p'{{ rootpass }}' -e "use mysql;update user set host = '%' where user ='root';flush privileges;"
